package com.alibaba.citrus.ots.sales.plan.facade.service.setting.contract.strategy.category;

import com.alibaba.citrus.ots.common.annotation.FacadeInvoker;
import com.alibaba.citrus.ots.sales.plan.api.setting.contract.trategy.ContractStatStrategy;
import com.alibaba.citrus.ots.sales.plan.functions.contract.ContractAbility;
import com.alibaba.citrus.ots.sales.plan.repository.ContractRepository;
import com.alibaba.citrus.ots.sales.plan.sdo.ContractSDO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wangyibing
 */
@Component("employeeCategoryDimension")
public class ContractEmployeeCategoryStrategyImpl implements ContractStatStrategy {
    @Resource
    private ContractRepository contractRepository;

    @Resource
    private ContractAbility contractAbility;

    @Override
    @FacadeInvoker
    public boolean summary(String contractYear) {
        //1、分组查询业务员类目维度的合同量明细
        List<ContractSDO> contractSDOList = contractRepository.queryGroupByEmployeeCategory(contractYear);
        //2、批量插入上一步查出来的合同量list
        Integer integer = contractAbility.batchCreateContract(contractSDOList);
        return contractSDOList.size() == integer;
    }
}
